#!/usr/bin/python -t
import commands
import sys
import string
import re

# RETURN CODE
# 0 = OK
# 1 = WARNING
# 2 = CRITICAL
# 3 = UNKNOWN

if len(sys.argv)<2:
	print "ERRORE PARAMETRI"
	sys.exit(3)  #UNKNOWN


CHECK_PROCESS=str(sys.argv[1])
strcom='/bin/ps axw |grep \"'+CHECK_PROCESS+'\" |grep -v \"grep\" |grep -v \"'+sys.argv[0]+'\"'
comdc=commands.getstatusoutput(strcom)
#print strcom
#print comdc
if re.search(CHECK_PROCESS,str(comdc)):
		print "OK: "+CHECK_PROCESS+ " alive"
		sys.exit(0)
else:
		print "CRITICAL: "+CHECK_PROCESS+ " die"
		sys.exit(2)
		


